#pragma once 
#include <iostream>
#include <fstream> // 包含文件流头文件，用于文件操作
using namespace std;

// 定义摄像头类
class Camera {
public:
    string model;          // 型号
    string cameraType;     // 摄像头类型
    int rgbResolutionWidth;     // RGB帧分辨率宽度
    int rgbResolutionHeight;    // RGB帧分辨率高度
    int rgbFrameRate;           // RGB帧率
    int fovHorizontal;          // 水平视场角
    int fovVertical;            // 垂直视场角
    int depthFrameRate;         // 深度帧率

    // 默认构造函数
    Camera()
        : model("Unknown"), cameraType("Unknown"), rgbResolutionWidth(0),
          rgbResolutionHeight(0), rgbFrameRate(0), fovHorizontal(0),
          fovVertical(0), depthFrameRate(0) {}

    // 构造函数
    Camera(string m, string ct, int rw, int rh, int rfr, int hfov, int vfov, int dfr)
        : model(m), cameraType(ct), rgbResolutionWidth(rw), rgbResolutionHeight(rh), rgbFrameRate(rfr),
          fovHorizontal(hfov), fovVertical(vfov), depthFrameRate(dfr) {}

    // 各属性的set方法
    void setModel(string newModel) {
        model = newModel;
    }

    void setCameraType(string newCameraType) {
        cameraType = newCameraType;
    }

    void setRGBResolutionWidth(int newRGBResolutionWidth) {
        rgbResolutionWidth = newRGBResolutionWidth;
    }

    void setRGBResolutionHeight(int newRGBResolutionHeight) {
        rgbResolutionHeight = newRGBResolutionHeight;
    }

    void setRGBFrameRate(int newRGBFrameRate) {
        rgbFrameRate = newRGBFrameRate;
    }

    void setFOVHorizontal(int newFOVHorizontal) {
        fovHorizontal = newFOVHorizontal;
    }

    void setFOVVertical(int newFOVVertical) {
        fovVertical = newFOVVertical;
    }

    void setDepthFrameRate(int newDepthFrameRate) {
        depthFrameRate = newDepthFrameRate;
    }

    // 打印双目摄像头信息
    void print() {
        cout << "双目摄像头型号: " << model << endl;
        cout << "RGB分辨率: " << rgbResolutionWidth << "x" << rgbResolutionHeight << endl;
        cout << "RGB帧率: " << rgbFrameRate << "fps" << endl;
        cout << "视场角: " << fovHorizontal << "x" << fovVertical << endl;
        cout << "深度帧率: " << depthFrameRate << "fps" << endl;
    }

    // 保存双目摄像头信息到本地文件
    void save(const string &filename) {
        ofstream outFile(filename, ios::app);  // 以追加模式打开文件
        if (!outFile.is_open()) {
            cerr << "无法打开文件 " << filename << endl;
            return;
        }
        outFile << "双目摄像头型号: " << model << endl;
        outFile << "RGB分辨率: " << rgbResolutionWidth << "x" << rgbResolutionHeight << endl;
        outFile << "RGB帧率: " << rgbFrameRate << "fps" << endl;
        outFile << "视场角: " << fovHorizontal << "x" << fovVertical << endl;
        outFile << "深度帧率: " << depthFrameRate << "fps" << endl;
        outFile.close();  // 关闭文件流
    }
};